ATOM Documentation

← Back to App

Setting up EventBridge Scheduler for Billing

This guide explains how to set up AWS EventBridge Scheduler to trigger the Atom SaaS billing engine periodically. This is the "Serverless Cron" pattern suitable for ATOM Cloud deployments.

Prerequisites

  1. **Deploy the latest backend code** (must include /api/billing/admin/report-usage).
  2. **Generate an ADMIN_API_KEY**:
  • This is a shared secret between your AWS EventBridge and your Atom Backend.
  • Generate one: openssl rand -hex 32
  • Add it to your Vault secrets: atom-cli secrets set ADMIN_API_KEY=your_generated_key

Setup Steps (AWS Console)

  1. **Go to Amazon EventBridge** -> **Scheduler** -> **Schedules**.
  2. Click **Create schedule**.
  3. **Schedule detail**:
  • **Name**: atom-billing-hourly
  • **Schedule pattern**: **Recurring schedule**
  • **Cron-based schedule**: 0 * * * ? * (Runs at minute 0 of every hour)
  • **Flexible time window**: **Off** (or 5 minutes if you don't mind variance)
  1. **Target detail**:
  • **Target API**: **Universal Target**
  • **Select target**: **HTTPS** (Send data to an HTTPS endpoint)
  • **URL**: https://[tenant].atomagentos.com/api/billing/admin/report-usage (Replace with your actual domain)
  • **Method**: POST
  • **HTTP Headers**:
  • **Name**: x-api-key
  • **Value**: your_generated_key (The ADMIN_API_KEY you set in ATOM Cloud)
  1. **Settings**:
  • **Retry policy**: Retry 3 times.
  • **Permissions**: Create a new execution role (AWS will handle this automatically).

Verification

  1. Wait for the top of the hour, or manually trigger the schedule.
  2. Check your application logs (atom-cli logs). You should see:
  3. Check Stripe Dashboard -> Subscriptions -> Usage to confirm the increment.